package com.chengdu.third.dao;

import com.chengdu.third.pojo.Ptype;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface IPtypeDao {

    /**
     * 查找所有
     * @return
     */
    @Select("select * from ptype")
    public List<Ptype> find();

    /**
     * 根据id删除
     * @param id
     */
    @Delete("delete from ptype where id  = #{id}")
    public void delete(long id);

    /**
     * 根据id修改
     * @param ptype
     */
    @Update("update ptype set rname = #{rname} where id = #{id}")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    public void update(Ptype ptype);

    /**
     * 增加
     * @param ptype
     */
    @Insert("insert into  ptype(`id`,`rname`) values(#{id},#{rname})")
    public void add(Ptype ptype);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from ptype where id = #{id}")
    public Ptype getPtypeById(long id);
}
